package com.hhit.zhgd.utils

import cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl
import org.apache.poi.ss.usermodel.CellStyle
import org.apache.poi.ss.usermodel.HorizontalAlignment
import org.apache.poi.ss.usermodel.VerticalAlignment
import org.apache.poi.ss.usermodel.Workbook

class CustomExcelExportStyler(workbook:Workbook):ExcelExportStylerDefaultImpl(workbook) {
    override fun getHeaderStyle(headerColor: Short): CellStyle? {
        val style = super.getHeaderStyle(headerColor)
        val font = workbook.createFont()
        font.bold = true
        font.fontHeightInPoints = 12.toShort()
        style.setFont(font)
        style.alignment = HorizontalAlignment.CENTER
        style.verticalAlignment = VerticalAlignment.CENTER
        return style
    }

    override fun getTitleStyle(color: Short): CellStyle? {
        val style = super.getTitleStyle(color)
        val font = workbook.createFont()
        font.bold = true
        font.fontHeightInPoints = 14.toShort()
        style.setFont(font)
        style.alignment = HorizontalAlignment.CENTER
        style.verticalAlignment = VerticalAlignment.CENTER
        return style
    }
}